var t = getApp(), a = require("../../../mybehaviors/location/location"), e = 2 * t.globalData.statusBarHeight + 20;

Page({
    behaviors: [ a ],
    data: {
        statusBarHeight: e,
        active: 0,
        project: "",
        goods: "",
        store: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        titleInfo: "",
        commentList: [],
        project_id: "",
        commentListtotal: 0
    },
    onLoad: function(a) {
        var e = this;
        console.log(a), this.setData({
            appointmentLang: wx.getStorageSync("yz_basic_info").lang.appointment,
            project_id: a.project_id
        }), wx.setNavigationBarTitle({
            title: this.data.appointmentLang.project + "详情"
        }), a.point && "undefined" != a.point ? (this.setData({
            point: JSON.parse(a.point)
        }), this.getData(), this.getNewList()) : this._getLocation(function(a, o) {
            var i = t.qqMapTransBMap(parseFloat(o.lng), parseFloat(o.lat));
            e.setData({
                lat: i.lat,
                lng: i.lng,
                point: i
            }), e.getData(), e.getNewList();
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {
        var t = wx.getStorageSync("yz_uid"), a = "";
        t && (a = t);
        var e = "/packageE/appointment/ProjectDetails/ProjectDetails?project_id=" + this.data.project_id + "&" + this.data.point + "&mid=" + a;
        return {
            title: this.data.appointmentLang.project + "详情",
            path: e
        };
    },
    goGoodsBtn: function(t) {
        var a = "/packageA/detail_v2/detail_v2?id=" + t.currentTarget.dataset.id;
        wx.navigateTo({
            url: a
        });
    },
    goHome: function() {
        wx.reLaunch({
            url: "/packageG/index/index"
        });
    },
    goMember: function() {
        wx.reLaunch({
            url: "/packageG/member_v2/member_v2"
        });
    },
    goBack: function() {
        getCurrentPages().length <= 1 ? wx.reLaunch({
            url: "/packageG/index/index"
        }) : wx.navigateBack({
            delta: 1
        });
    },
    toRouter: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageC/o2o/HomeSeller/HomeSeller?store_id=" + a
        });
    },
    swichTabTItem: function(t) {
        this.setData({
            active: t.detail.index
        }), 2 == this.data.active && 0 == this.data.commentList.length && this.getComment();
    },
    getComment: function() {
        var a = this, e = t.getNetAddresss("plugin.appointment.frontend.comment.get-comment-by-project-id");
        t._getNetWork({
            url: e,
            data: {
                page: this.data.page,
                project_id: this.data.project_id
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.setData({
                    isLoadMore: !0,
                    total_page: e.data.last_page,
                    commentList: e.data.data,
                    commentListtotal: e.data.total
                }), a.data.total_page || a.setData({
                    total_page: 0
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    MoreStore: function() {
        wx.navigateTo({
            url: "/packageE/appointment/sotoreList/sotoreList?project_id=" + this.data.project_id + "&point=" + JSON.stringify(this.data.point)
        });
    },
    getNewList: function() {
        var a = this, e = t.getNetAddresss("plugin.appointment.frontend.project.getDetailStore");
        t._getNetWork({
            url: e,
            data: {
                lng: this.data.point.lng,
                lat: this.data.point.lat,
                project_id: this.data.project_id
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    store: e.data.data,
                    storeLast: e.data
                }) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var a = this;
        if (this.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            var e = this.data.page + 1;
            this.setData({
                page: e
            });
            var o = t.getNetAddresss("plugin.appointment.frontend.comment.get-comment-by-project-id");
            t._getNetWork({
                url: o,
                data: {
                    page: this.data.page,
                    project_id: this.data.project_id
                },
                success: function(t) {
                    var e = t.data;
                    if (1 == e.result) {
                        var o = e.data.data.concat(a.data.commentList);
                        a.setData({
                            commentList: o
                        });
                    } else {
                        wx.showToast({
                            title: e.msg,
                            icon: "none"
                        });
                        var i = a.data.page - 1;
                        a.setData({
                            page: i,
                            isLoadMore: !1
                        });
                    }
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    getData: function() {
        var a = this, e = t.getNetAddresss("plugin.appointment.frontend.project.get-detail-by-id");
        t._getNetWork({
            url: e,
            data: {
                lng: this.data.point.lng,
                lat: this.data.point.lat,
                project_id: this.data.project_id
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.setData({
                    project: e.data.project,
                    goods: e.data.goods
                }), a.getComment()) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});